package com.bz.content.controller;

import com.bz.content.service.ContentCategoryService;
import com.bz.pojo.TbContentCategory;
import com.bz.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/content")
public class ContentCategoryController {

    @Autowired
    private ContentCategoryService contentCategoryService;

    /**
     * 根据父节点ID查询子节点
     * @param parentId
     * @return
     */
    @GetMapping("/selectContentCategoryByParentId")
    public Result selectContentCategoryByParentId(@RequestParam(defaultValue = "0") Long parentId){
        return contentCategoryService.selectContentCategoryByParentId(parentId);
    }

    /**
     * 添加内容分类
     * @param tbContentCategory
     * @return
     */
    @PostMapping("/insertContentCategory")
    public Result insertContentCategory(TbContentCategory tbContentCategory){
        return contentCategoryService.insertContentCategory(tbContentCategory);
    }

    /**
     * 删除内容分类
     * @param id
     * @return
     */
    @GetMapping("/deleteContentCategoryById")
    public Result deleteContentCategoryById(Long id){
        return contentCategoryService.deleteContentCategoryById(id);
    }

    /**
     * 修改内容分类名称
     * @param tbContentCategory
     * @return
     */
    @PostMapping("/updateContentCategory")
    public Result updateContentCategory(TbContentCategory tbContentCategory){
        return contentCategoryService.updateContentCategory(tbContentCategory);
    }
}
